package com.md.facade;

import com.md.api.UsersApi;
import com.md.application.service.UsersApplication;
import com.md.base.request.IdRequest;
import com.md.config.Logs;
import com.md.model.page.PageResponse;
import com.md.model.system.CommonResult;
import com.md.request.LinkRoleRequest;
import com.md.request.LoginRequest;
import com.md.request.QueryUsersPageRequest;
import com.md.request.RegisterUsersRequest;
import com.md.response.UsersDetailResponse;
import com.md.response.UsersResponse;
import com.md.value.enums.OperationEnum;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 刘骄阳
 * 2024-12-15 1:41
 */
@RestController
@RequiredArgsConstructor
public class UsersController implements UsersApi {
  private final UsersApplication usersApplication;

  @Override
  @Logs(title = "注册用户", operation = OperationEnum.INSERT)
  public CommonResult<UsersResponse> register(final RegisterUsersRequest request) {
    return usersApplication.register(request);
  }

  @Override
  @Logs(title = "注册用户-校验参数", operation = OperationEnum.SELECT)
  public CommonResult<Void> checkUserFormat(final RegisterUsersRequest request) {
    return usersApplication.checkUserFormat(request);
  }

  @Override
  @Logs(title = "用户关联角色", operation = OperationEnum.INSERT)
  public CommonResult<Void> linkRole(final LinkRoleRequest request) {
    return usersApplication.linkRole(request);
  }

  @Override
  @Logs(title = "查询用户列表", operation = OperationEnum.SELECT)
  public CommonResult<PageResponse<UsersResponse>> list(final QueryUsersPageRequest request) {
    return usersApplication.list(request);
  }

  @Override
  @Logs(title = "查询用户详情", operation = OperationEnum.SELECT)
  public CommonResult<UsersDetailResponse> detail(final IdRequest request) {
    return usersApplication.detail(request);
  }

  @Override
  @Logs(title = "登陆", operation = OperationEnum.SELECT)
  public CommonResult<UsersDetailResponse> login(final LoginRequest request) {
    return usersApplication.login(request);
  }
}
